<?php
set_time_limit(0);

$file_name = 'search.css';

$cnt = file_get_contents($file_name);

preg_match_all("#http[\s\S]+?([^\/]+\.(?:jpg|png|gif|jpeg))#",$cnt,$arr);

foreach($arr[0] as $key => $img){
	$img_cnt = file_get_contents($img);
	file_put_contents(__DIR__ . '/images/' . $arr[1][$key], $img_cnt);
	$cnt = str_replace($img,'/shop/templates/template1/Css/images/' . $arr[1][$key],$cnt);
}

file_put_contents($file_name,$cnt);

echo 'success';